<?php
namespace frontend\models;

use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;
use yii\db\Query;
use yii\web\IdentityInterface;


class HryMember extends ActiveRecord
{
    public static function getDb()
    {
        return \Yii::$app->db2;  // 使用名为 "db2" 的应用组件,好融艺数据库链接
    }

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%tf_member}}';
    }

//    /**
//     * @inheritdoc
//     */
//    public function behaviors()
//    {
//        return [
//            TimestampBehavior::className(),
//        ];
//    }

    /**
     * 好融艺
     * @param $member_info
     * @author hey_heyang(635870453@qq.com)
     * @return bool
     */
    public  function  insertHryMemberInfo($member_info){
        if(empty($member_info)) return false;
        try{
            $hry_member_info=$this->find()->where(['mobile'=>$member_info['mobile']])->one();
            $id=0;
            if(empty($hry_member_info)){
                $this->mobile =$member_info['mobile'];
                $this->password =$member_info['password'];
                $this->create_time =time();
                $this->update_time =time();
                $this->is_disable=1;
                $this->save();
                $id= $this->attributes['id'];;
            }
            return $id;
        }catch (\Exception $e){
            file_put_contents(BASE_PATH.'log/'.date("Y-m-d H", time()).'hry_member_error.txt',str_replace("\\", "", json_encode($member_info,JSON_UNESCAPED_UNICODE)).PHP_EOL,FILE_APPEND);
            return true;
        }
    }


}
